* =init.el=

#+begin_src elisp
;;; PYTHON IDE FEATURES

;;; EGLOT SETUP

;; using eglot for lsp
(use-package eglot
  :ensure t
  :defer t
  :hook (python-mode . eglot-ensure))

;; using emacs-pet to find correct python executable in venv and so on
(use-package pet
  :ensure t
  :config
  (add-hook 'python-base-mode-hook 'pet-mode -10))

;; to set up python-mode to use the correct interpreter when you execute M-x run-python
(add-hook 'python-mode-hook
          (lambda ()
            (setq-local python-shell-interpreter (pet-executable-find "python")
                        python-shell-virtualenv-root (pet-virtualenv-root))))

;; to help you setup the flake8, pylint and mypy checkers
(add-hook 'python-mode-hook 'pet-flycheck-setup)
#+end_src

* Emacs Python Venv

This venv must be somewhere visible to =emacs-pet=.

#+begin_src shell
python3 -m venv python-venv
. python-venv/bin/activate
command -V python3
python3 -m pip install python-lsp-server
#+end_src

* =.dir-locals.el= in project root

#+begin_src elisp
;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((python-mode . ((eglot-workspace-configuration
                  . ((pylsp (plugins
                             (mccabe (enabled . nil))
                             (pycodestyle (enabled . nil))
                             (flake8 (enabled . t))
                             (pylint (enabled . nil))
                             (mypy (enabled . t))
                             (isort (enabled . t))))
                     (pyls (plugins
                            (mccabe (enabled . nil))
                            (pylint (enabled . nil))
                            (pycodestyle (enabled . nil))
                            (flake8 (enabled . t))
                            (mypy (enabled . t))
                            (isort (enabled . t)))))))))
#+end_src

* =.flake8= in project root

Configure flake8 as you want:

#+begin_src toml
[flake8]
max-line-length = 120
exclude = venv, .venv
extend-ignore = E501,D100
#+end_src
